<%@ page import="BusinessLogic.ControllerFacade" %>
<%@ page import="Domain.Exceptions.UserNotLoggedInException" %>
<%@ page import="Domain.DataStructures.IUserData" %>
<%@ page errorPage="error.jsp" %>

<%
    ControllerFacade c = (ControllerFacade) session.getAttribute("c");
    boolean connected;    
    IUserData user = null;
    try {        
        user = c.getCurrentUser();
        connected = true;
    } catch (UserNotLoggedInException e) {
        connected = false;
    }
%>

<h2>Please fill all the fields</h2>

<form action="index.jsp" method="post">
    <table width="100%">
        <tr>
            <td>
                <input type="hidden" name="action" value="PreformRegister" />
            </td>
        </tr>
        <tr>
            <td>
                <label title="username">Username</label>
            </td>
            <td>
                <input type="text" name="username" id="username" />
            </td>
        </tr>
        <tr>
            <td>
                <label title="password">Password</label>
            </td>
            <td>
                <input type="password" name="password" id="password" />
            </td>
        </tr>        
        <tr>
            <td>
                <label title="first">First Name</label>
            </td>
            <td>
                <input type="text" name="first" id="first" />
            </td>
        </tr>
        <tr>
            <td>
                <label title="last">Last Name</label>
            </td>
            <td>
                <input type="text" name="last" id="last" />
            </td>
        </tr>
        <tr>
            <td>
                <label title="email">Email Address</label>
            </td>
            <td>
                <input type="text" name="email" id="email" />
            </td>
        </tr>
<%
    if (connected && user.isAdministrator()) {
%>
        <tr>
            <td>
                <label title="vip">Choose Is VIP</label>
            </td>
            <td>
                <select name="vip" id="vip">
                    <option value="false">No</option>
                    <option value="true">Yes</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>
                <label title="acl">Choose Access Level</label>
            </td>
            <td>
                <select name="acl" id="acl">
                    <option value="User">User</option>
                    <option value="Manager">Manager</option>
                    <option value="Administrator">Administrator</option>
                </select>
            </td>
        </tr>
<%
    }
%>
    </table>
    <p class="submit">
        <input type="submit" value="Ok, Let's register" />
    </p>
</form>

